var spider = require('./main');
var _ = require('lodash');
var moment = require('moment');
var PostController = require('./controller/PostController');
var NewsController = require('./controller/NewsController');
var CronJob = require('cron').CronJob;
var crypto = require('crypto');
var async = require('async');

var hulianwang_url = 'http://rss.it.sohu.com/rss/hulianwang.xml';
spider.FetchRss(hulianwang_url).then(function(data){
  async.mapSeries(data,function(i,callback){
    console.log(i);
    // var md5 = crypto.createHash('md5');
    // NewsController.create({
    //   title:i.title,
    //   link:i.link,
    //   date: i.date == 'Invalid Date' ? '' : moment(i.date).format('YYYY-MM-DD HH:mm:ss'),
    //   author:i.author,
    //   description:i.description,
    //   guid:md5.update(i.guid).digest('hex'),
    //   cate:'sohu',
    //   c_cate:'互联网'
    // },function(err){
    //   if(err) return done(err);
    //   callback(null,[]);
    // });
    callback(null);
  },function(err,res){
    done(null,'sohu-互联网');
  });
});

